

const selectLoadMore = (element, binding) => {
    const { scrollTop, scrollHeight, clientHeight } = element,
      scrollDistance = scrollHeight - scrollTop - clientHeight;
    if (scrollDistance <= 0) {
      binding.value();
    }
  }
export default {
    install(app) {
        app.directive("selectLoadMore", {
            mounted(el, binding) {
                const className = `.${el.dataset.class}`, element = document.querySelector(className)?.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
                element?.addEventListener("scroll", () => {
                    selectLoadMore(element, binding);
                })
            },
            beforeUnmount(el, binding) {
                const className = `.${el.dataset.class}`, element = document.querySelector(className)?.querySelector(".el-select-dropdown .el-select-dropdown__wrap");
                element?.removeEventListener("scroll", () => {
                    selectLoadMore(element, binding);
                })
              }
        })
    }
}
